function changebuniss(){
	document.getElementById("bunissdiv").style.background="orangered";
	document.getElementById("workdiv").style.background="coral";
	document.getElementById("bunissregist").style.display="block";
	document.getElementById("workregist").style.display="none";
}

function changework(){
	document.getElementById("workdiv").style.background="orangered";
	document.getElementById("bunissdiv").style.background="coral";
	document.getElementById("bunissregist").style.display="none";
	document.getElementById("workregist").style.display="block";
}
getworkrole();
function getworkrole(){
	var role =document.getElementById("role");

	$.ajax({
		url:"getrole",
		type:"post",
		dataType:"json",
		async:true,
		data:{},
		success:function (data){
			var str =""
			for(var i =0 ; i<data.length;i++){
				str+=`<option value ="`+data[i].wtId+`">`+data[i].wtName+`</option>`
			}
			role.innerHTML=str;
		},
		error:function (data){
			alert("请求失败");
		}
	})
}

function workregist(){
	var workname =document.getElementById("workname").value;
	var workphone =document.getElementById("workphone").value;
	var workage =document.getElementById("workage").value;
	var worknumber =document.getElementById("worknumber").value;
	var workpass =document.getElementById("workpass").value;
	var workpass2 =document.getElementById("workpass2").value;
	var role =document.getElementById("role");

	var roleindex =role.selectedIndex;
	var roleoption = role.options[roleindex].value;


	var workquestion =document.getElementById("workquestion");
	var workquestionindex =workquestion.selectedIndex;
	var workquestionoption = workquestion.options[workquestionindex].value;

	var workanswer =document.getElementById("workanswer").value;

	$.ajax({
		url:"workregist",
		dataType: "json",
		type: "post",
		async: true,
		data: {workname,workphone,workage,worknumber,workpass,workpass2,roleoption,workquestionoption,workanswer},
		success:function (data){
			if(data.inf==="注册成功"){
				alert("注册成功，您的账号是"+data.account);
				location.href="login.html";
			}
			alert(data.inf);
		},
		error:function (data){
			alert("请求失败");
		}

	})
}